<!--{subtemplate inc/header}-->
<script type="text/javascript">
<!--{dynamic getGoodsDynamics args=$goods_result['ids']}-->
</script>
<!--{advlayout id="首页顶部通栏广告宽990px"}-->
<div class="blank12"></div>
<div class="hbox">
	<div class="list-goods-search">
		<!--{if $city_areas}-->
		<!--{eval $cache_areas = $_FANWE['cache']['city_area_'.CURRENT_CITY_PY];}-->
		<!--{if $area_id > 0}-->
		<!--{eval $aroot_id = $area_id;}-->
		<!--{eval $current_area = $cache_areas['all'][$area_id];}-->
		<!--{if $current_area['parent_id'] > 0}-->
		<!--{eval $aroot_id = $current_area['parent_id'];}-->
		<!--{/if}-->
		<!--{/if}-->
		
		<div class="lgs-item lgs-area parent-area">
			<div class="lgsi-title">商圈</div>
			<div class="lgsi-list">
				<a href="javascript:;" class="{if $area_id == 0}active{/if}" areaID="0">全部 <span>($city_areas['gcount'])</span></a>
				<!--{loop $cache_areas['roots'] $rootid}-->
				<!--{eval $root_area = $cache_areas['all'][$rootid];}-->
				<!--{eval $root_count = $city_areas['areas'][$root_area['name']];}-->
				<a href="javascript:;" class="{if $aroot_id == $rootid}active{/if}{if $root_count == 0} disabled{/if}" areaID="$rootid">$root_area['name'] <span>($root_count)</span></a>
				<!--{/loop}-->
			</div>
		</div>
		<!--{eval $root_area = $cache_areas['all'][$aroot_id];}-->
		<!--{if isset($root_area['childs'])}-->
		<div class="lgs-item area-sub lgs-area" rel="$rootid">
			<div class="lgsi-list">
				<strong>$root_area['name']:</strong>
				<div>
					<!--{loop $root_area['childs'] $childid}-->
					<!--{eval $area = $cache_areas['all'][$childid];}-->
					<!--{eval $area_count = $city_areas['areas'][$area['name']];}-->
					<a href="javascript:;" class="{if $area_id == $childid}active{/if}{if $area_count == 0} disabled{/if}" areaID="$childid">$area['name'] <span>($area_count)</span></a>
					<!--{/loop}-->
				</div>
			</div>
		</div>
		<!--{/if}-->
		<!--{/if}-->
		<!--{if $cate_id > 0}-->
		<!--{eval $root_id = $cate_id;}-->
		<!--{eval $current_cate = $_FANWE['cache']['goods']['cats'][$cate_id];}-->
		<!--{if $current_cate['pid'] > 0}-->
		<!--{eval $root_id = $current_cate['pid'];}-->
		<!--{/if}-->
		<!--{/if}-->
		<div class="lgs-item lgs-cate">
			<div class="lgsi-title">分类</div>
			<div class="lgsi-list">
				<a href="javascript:;" class="{if $cate_id == 0}active{/if}" cateID="0">全部 <span>($goods_cates['gcount'])</span></a>
				<!--{loop $_FANWE['cache']['goods']['root_cates'] $rootid}-->
				<!--{eval $root_count = $goods_cates['cates'][$rootid];}-->
				<!--{eval $root_cate = $_FANWE['cache']['goods']['cats'][$rootid];}-->
				<a href="javascript:;" class="{if $root_id == $rootid}active{/if}{if $root_count == 0} disabled{/if}" cateID="$rootid">$root_cate['name'] <span>($root_count)</span></a>
				<!--{/if}-->
			</div>
		</div>
		<!--{eval $root_cate = $_FANWE['cache']['goods']['cats'][$root_id];}-->
		<!--{if isset($root_cate['childs'])}-->
		<div class="lgs-item cate-sub lgs-cate">
			<div class="lgsi-list">
				<strong>$root_cate['name']:</strong>
				<!--{loop $root_cate['childs'] $childid}-->
				<!--{eval $cate_count = $goods_cates['cates'][$childid];}-->
				<!--{eval $cate = $_FANWE['cache']['goods']['cats'][$childid];}-->
				<a href="javascript:;" class="{if $cate_id == $childid}active{/if}{if $cate_count == 0} disabled{/if}" cateID="$childid">$cate['name'] <span>($cate_count)</span></a>
				<!--{/loop}-->
			</div>
		</div>
		<!--{/if}-->
		<div class="lgs-item lgs-price">
			<div class="lgsi-title">价格</div>
			<div class="lgsi-list">
				<a href="javascript:;"{if empty($prices)} class="active"{/if} price="0,0">全部</a>
				<a href="javascript:;"{if $prices == '0,100'} class="active"{/if} price="0,100">0-100元</a>
				<a href="javascript:;"{if $prices == '100,300'} class="active"{/if} price="100,300">100-300元</a>
				<a href="javascript:;"{if $prices == '300,500'} class="active"{/if} price="300,500">300-500元</a>
				<a href="javascript:;"{if $prices == '500,0'} class="active"{/if} price="500,0">500元以上</a>
			</div>
		</div>
	</div>
	<div class="list-goods-sort">
		<div class="actions">
			<a href="{u now/index}"{if ACTION_NAME == 'index'} class="current"{/if}>所有团购</a>
			<a href="{u now/today}"{if ACTION_NAME == 'today'} class="current"{/if}>今日发布</a>
			<a href="{u now/custom}"{if ACTION_NAME == 'custom'} class="current"{/if}>个人定制</a>
		</div>
		<div class="sort">
			<a href="javascript:;"{if empty($sort)} class="default"{/if} sort="">默认排序</a>
			<a href="javascript:;"{if $sort == 'spd'} class="currentd" sort="spa"{elseif $sort == 'spa'} class="currenta" sort="spd"{else} sort="spa"{/if}>价格排序</a>
			<a href="javascript:;"{if $sort == 'dd'} class="currentd" sort="da"{elseif $sort == 'da'} class="currenta" sort="dd"{else} sort="da"{/if}>折扣排序</a>
			<a href="javascript:;"{if $sort == 'bd'} class="currentd" sort="ba"{elseif $sort == 'ba'} class="currenta" sort="bd"{else} sort="bd"{/if}>销量排序</a>
			<a href="javascript:;"{if $sort == 'etd'} class="currentd" sort="eta"{elseif $sort == 'eta'} class="currenta" sort="etd"{else} sort="eta"{/if}>时间排序</a>
		</div>
		<div class="display {dynamic getDisplayMode}">
			<a href="javascript:;" class="d_grid" mode="grid">网格</a>
			<a href="javascript:;" class="d_row" mode="row">列表</a>
		</div>
	</div>
	<!--{if defined('IS_CUSTOM_SITE')}-->
	<div class="goods-custom-info" style="width:988px;">
		<div class="msg">提示：您现在位于个人定制的团购网站页,要查看其它团购，请通过上面的"所有团购"或"今日发布"链接进行查看！</div>
		<div class="btns">点击&nbsp;<input class="smallbtn" type="button" value="管理定制团购网" />&nbsp;可以添加或删除定制的团购网站。<a href="javascript:;">如何使用个人定制功能？</a></div>
		<div class="info">
			这么多的团购网站，看的我眼花缭乱，我该怎么办呢？"个人定制团购"为您量身打造属于自己的团购导航。<br/>
			首先，点击"管理定制团购网"链接。<br/>
			然后选中自己喜欢的团购网站。<br/>
			最后点击"保存"按钮就可以成功定制个人的团购信息了：），还等什么呢，快点试试吧！
		</div>
	</div>
	<!--{/if}-->
	<div id="list_goods_body">
	<div id="goods_list_body" class="list-{dynamic getDisplayMode}-body">
		<!--{if count($goods_result['list']) > 0}-->
		<ul>
			<!--{loop $goods_result['list'] $goods}-->
			<!--{if defined('IS_CACHE_TPL')}-->
			<!--{eval $goods['bought'] = '<script type="text/javascript">document.write(goodsDynamics["g_'.$goods['id'].'"]["bought"]);</script>';}-->
			<!--{eval $goods['post_count'] = '<script type="text/javascript">document.write(goodsDynamics["g_'.$goods['id'].'"]["post"]);</script>';}-->
			<!--{eval $goods['collect_count'] = '<script type="text/javascript">document.write(goodsDynamics["g_'.$goods['id'].'"]["collect"]);</script>';}-->
			<!--{eval $goods['click_count'] = '<script type="text/javascript">document.write(goodsDynamics["g_'.$goods['id'].'"]["click"]);</script>';}-->
			<!--{/if}-->
			<li class="item">
				<div class="site_gname">
					<div class="site">
						<a href="$goods[site_url]" target="_blank">$goods[site_name]</a>
					</div>
					<div class="name">
						<a href="$goods[url]" target="_blank" title="{$goods[site_name]}：{$goods[city]}今日团购:$goods[name]" style="text-align:left;">$goods[name]</a>
					</div>
				</div>
				<div class="img">
					<a href="$goods[url]" target="_blank"><img src="$goods[small_img]" alt="{$goods[site_name]}：{$goods[city]}今日团购:$goods[name]" /></a>
				</div>
				<div class="attrs-list">
					<p class="sprice al">现价：<span>$goods[shop_price_format]</span></p>
					<p class="bought ar">销量：<span>$goods[bought]</span></p>
					<p class="mprice al">原价：<b>$goods[market_price_format]</b></p>
					<p class="post ar">评论：<span>$goods[post_count]</span></p>
					<p class="discount al">折扣：<span>$goods[discount]</span>折</p>
					<p class="collect ar">收藏：<span>$goods[collect_count]</span></p>
					<p class="buy al"><a href="$goods[url]" target="_blank"><img src="{TPL_PATH}images/btn-1.gif" /></a></p>
					<p class="click ar">点击：<span>$goods[click_count]</span></p>
				</div>
				<div class="attrs-text attrs1">
					现价：<span class="sprice">$goods[shop_price_format]</span>
					原价：<b>$goods[market_price_format]</b>
					折扣：<span>$goods[discount]折</span>
					销量：<span>$goods[bought]</span>
				</div>
				<div class="attrs-text attrs2">
					<p class="post">评论：<span>$goods[post_count]</span></p>
					<p class="collect">收藏：<span>$goods[collect_count]</span></p>
					<p class="click">点击：<span>$goods[click_count]</span></p>
					<p class="buy"><a href="$goods[url]" target="_blank"><img src="{TPL_PATH}images/btn-1.gif" /></a></p>
				</div>
				<div class="time settime" endTime="$goods[end_time]">
					$goods[end_time_lag]
				</div>
				<!--{if $goods['is_best'] == 1}-->
				<span class="best"></span>
				<!--{elseif $goods['is_new'] == 1}-->
				<span class="new"></span>
				<!--{/if}-->
			</li>
			<!--{/loop}-->
		</ul>
		<!--{else}-->
		<!--{if defined('IS_CUSTOM_SITE') && $no_query}-->
		<div class="empty">你还没有定制团购网站！</div>
		<!--{else}-->
		<div class="empty">没有找到符合条件的团购活动！</div>
		<!--{/if}-->
		<!--{/if}-->
		<!--{subtemplate inc/pages}-->
		<div class="blank20"></div>
	</div>
	</div>
</div>
<script type="text/javascript">
var cat = "$cate_id";
var city = "{CURRENT_CITY_PY}";
var sortOrder = "$sort";
var area = "$area_id";
var prices = "{$prices}";
var route = $_FANWE['setting']['url_route'];
var depr = "-";
var indexUrl = decodeURIComponent("{echo U('now/'.ACTION_NAME,array('cat'=>'_cat_','city_py'=>'_city_','sort'=>'_sort_','prices'=>'_prices_','area'=>'_area_'))}");
var customSiteCount = 12;

jQuery(function($){
	$(".img img").lazyload({"placeholder":"{TPL_PATH}images/img_loading.gif","failurelimit":10});
	
	$(".area-sub").show();
	
	$(".area-sub").each(function(){
		var title_width = $('strong',this).width();
		$('.lgsi-list div',this).width(903 - title_width);
	});
	
	$(".sia").hover(function(){
		$(".sia").removeClass("active");
		$(this).addClass("active");
	},function(){
		$(this).removeClass("active");
	});
	
	$(".lgs-cate a").click(function(){
		if($(this).hasClass('disabled'))
			return false;
		cat = this.getAttribute("cateID");
		goToUrl();
	});
	
	$(".lgs-area a").click(function(){
		if($(this).hasClass('disabled'))
			return false;
		
		area = this.getAttribute("areaID");
		goToUrl();
	});
	
	$(".list-goods-sort .sort a").click(function(){
		sortOrder = this.getAttribute("sort");
		goToUrl();
	});
	
	$(".lgs-price a").click(function(){
		prices = this.getAttribute("price");
		goToUrl();
	});
	
	$(".list-goods-sort .display a").click(function(){
		mode = this.getAttribute("mode");
		$.cookie(COOKIE_PRE + 'display_mode', mode,{"expires":7});
		$("#goods_list_body").attr("className","list-"+mode+"-body");
		$(".list-goods-sort .display").attr("className","display "+mode);	
	});
	
	<!--{if defined('IS_CUSTOM_SITE')}-->
	$(".goods-custom-info .btns a").click(function(){
		$(".goods-custom-info .info").toggle();
	});
	
	$(".goods-custom-info .btns input").click(function(){
		$.showWindow({"title":"定制个人团购网站(最多可添加12个)","html":'<div class="select_sites"></div>',"msg":"提示：如果您选了其它城市才有的团购网，只有在切换到该城市后您才能看到相应的定制信息。"});
		$.showLoading("#fwindow .fwindow_content");
		$.ajax({
			type: "GET",
			dataType: "html",
			cache:false,
			url: SITE_PATH + "/services/ajax.php",
			data:{"action":"custom_site"},
			success: function(html){
				$("#fwindow .select_sites").html(html);
				$.closeLoading("#fwindow .fwindow_content");
				
				$(".select_sites .ss_tabs .item").click(function(){
					$(".select_sites .ss_tabs .item").removeClass("current");
					$(this).addClass("current");
					
					$(".select_sites .sites_box").hide();
					$(".select_sites .sites_box[rel='"+this.getAttribute("rel")+"']").show();
				});
				
				$(".select_sites .sites_py li").click(function(){
					$("li",$(this).parent()).removeClass("current");
					$(this).addClass("current");
					
					$("dl",$(this).parent().parent()).hide();
					$("dl[rel='"+this.getAttribute("rel")+"']",$(this).parent().parent()).show();
				});
				
				$(".select_sites .sites_box label input").change(function(){
					
					$(".select_sites .sites_box input.site_id_"+this.value).attr("checked",this.checked);
					var siteCount = getCustomSiteInfo()[1];
					
					if(siteCount <= customSiteCount)
					{
						$(".select_sites .custom_count").html(siteCount);
					}
					else
					{
						$(".select_sites .sites_box input.site_id_"+this.value).attr("checked",false);
						alert("最多可定制"+customSiteCount+"个团购网站");
					}
				});
				
				$(".select_sites .custom_count").html(getCustomSiteInfo()[1]);
				$(".select_sites .sites_box label input").each(function(i){
					if(this.checked)
					{
						$(".select_sites .sites_box input.site_id_"+this.value).attr("checked",true);
					}
				});
				
				$(".select_sites .save_select_site").click(function(){
					var customInfo = getCustomSiteInfo();
					if(customInfo[1] > customSiteCount)
					{
						alert("最多可定制"+customSiteCount+"个团购网站");
					}
					else
					{
						$.showLoading("#fwindow .fwindow_content");
						$.ajax({
							type: "GET",
							cache:false,
							url: SITE_PATH + "/services/ajax.php",
							data: {"action":"save_custom_site","site_ids":customInfo[0]},
							success: function(data){
								$.closeLoading("#fwindow .fwindow_content");
								$("#fwindow .fwindow_close").click();
							},
							error:function(r, t, e){
								$.closeLoading("#fwindow .fwindow_content");
								alert('保存定制信息失败，请重新保存或联系管理员！');
							}
						});
					}
				});
			}
		});
	});
	<!--{/if}-->
});

function getCustomSiteInfo()
{
	var siteIds = '';
	$(".select_sites .sites_box label input").each(function(i){
		if(this.checked)
		{
			if(siteIds == '')
				siteIds += this.value;
			else
			{
				if((','+siteIds+',').indexOf(','+this.value+',') < 0)
					siteIds+= ',' + this.value;
			}
		}
	});
	
	if(siteIds != '')
		return [siteIds,siteIds.split(',').length];
	else
		return ['',0];
}

function goToUrl()
{
	if(cat == 0)
		indexUrl = clearParm(indexUrl,'_cat_',"",'cat');
	else
		indexUrl = clearParm(indexUrl,'_cat_',cat,'cat');
		
	if(area == 0)
		indexUrl = clearParm(indexUrl,'_area_',"",'area');
	else
		indexUrl = clearParm(indexUrl,'_area_',area,'area');
	
	if(prices == "0,0")
		indexUrl = clearParm(indexUrl,'_prices_',"",'prices');
	else
		indexUrl = clearParm(indexUrl,'_prices_',prices,'prices');
	
	indexUrl = clearParm(indexUrl,'_city_',city,'city_py');
	indexUrl = clearParm(indexUrl,'_sort_',sortOrder,'sort');
    
    //2011-02-10 update
    var fun = function(){
        location.href=indexUrl;
    };

    setTimeout(fun,1);
}

function clearParm(url,search,replace,parm)
{
	if(replace == "")
	{
		if(route > 0)
			return url.replace(depr+parm+depr+search,"");
		else
			return url.replace("&"+parm+"="+search,"");
	}
	else
		return url.replace(search,replace);
}
</script>
<!--{subtemplate inc/footer}-->